    {include file="../view/head" /}
    <style>
        #user_list .panel-heading>form{
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-right: 40px;
        }
        #user_list .panel-heading>form>div>label{
            width: 100%;
            background: #666;
            color: #fff;
            border-radius: 4px 4px 0 0;
            border: 1px solid #666;
            margin: 0;
            text-align: center;
        }
        #user_list .panel-heading>form>div>.form-control{
            border-radius: 0 0 4px 4px;
            border: 1px solid #666;
            padding: 0;
            height: auto;
        }
        td>.btn{font-weight: normal;}
    </style>
    </head>
    <body>
        {include file="../view/header" /}
        {include file="../view/sidebar" /}
        {include file="../view/right-sidebar" /}
        <!-- Start #content -->
        <div id="content">
            <!-- Start .content-wrapper -->
            <div class="content-wrapper">
                <div class="row">
                    <!-- Start .row -->
                    <!-- Start .page-header -->
                    <div class="col-lg-12 heading hidden-xs hidden-sm">
                        <!-- Start .bredcrumb -->
                        <ul id="crumb" class="breadcrumb"></ul>
                        <!-- End .breadcrumb -->
                    </div>
                    <!-- End .page-header -->
                </div>
                <!-- End .row -->
                <div class="outlet">
                    <!-- Start .outlet -->
                    <!-- Page start here ( usual with .row ) -->
                    <div class="row">
                        <div class="col-md-12" id="user_list">
                            <!-- col-lg-12 start here -->
                            <div class="panel panel-default toggle panelRefresh">
                                <!-- Start .panel -->
                                <div class="panel-heading" style="padding: 10px 15px;">
                                    <form action="{:url('users/user_list')}" method="post">
                                        {:token()}
                                        <a href="{:url('users/user_list')}" class="btn btn-primary">恢复<br>默认</a>
                                        <div style="width:110px;">
                                            <label>搜索用户</label>
                                            <input class="form-control" type="number" name="uname" value="{$param.uname?:''}" oninput="if(value.length>11)value=value.slice(0,11)">
                                        </div>
                                        <div style="width:55px;">
                                            <label>状态</label>
                                            <select name="zt" class="form-control">
                                                <option value="">全部</option>
                                                <option value="1">正常</option>
                                                <option value="2">封号</option>
                                                <option value="3">冻结</option>
                                            </select>
                                        </div>
                                        <div style="width:80px;">
                                            <label>排序</label>
                                            <select name="orderby" class="form-control">
                                                <option value="regtime">注册时间</option>
                                                <option value="loginnum">登陆次数</option>
                                                <option value="tj_num">直推推荐</option>
                                                <option value="idc">可售币</option>
                                                <option value="power">算力</option>
                                            </select>
                                            <select name="ordersc" class="form-control">
                                                <option value="desc">倒叙</option>
                                                <option value="asc">升序</option>
                                            </select>
                                        </div>
                                        <button type="submit" class="btn btn-primary">筛<br/>选</button>
                                    </form>
                                </div>
                                <div class="panel-body">
                                    <table class="table table-bordered table-hover table-striped">
                                        <thead>
                                            <tr>
                                                <th class="per5">
                                                    <label class="checkbox">
                                                        <input class="check-all" type="checkbox">
                                                    </label>
                                                </th>
                                                <th>用户名</th>
                                                <th>姓名</th>
                                                <th>推荐人</th>
                                                <th>状态</th>
                                                <th>直推人数</th>
                                                <th>可售币</th>
                                                <th>买币数量</th>
                                                <th>矿机数量</th>
                                                <th>个人算力</th>
                                                <th>注册时间</th>
                                                <th>注册地址</th>
                                                <th>离线时长</th>
                                                <th>操作</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        {foreach $lists as $user} 
                                            <tr>
                                                <td>
                                                    <label class="checkbox">
                                                        <input class="check" type="checkbox" value="{$user.id}">
                                                    </label>
                                                </td>
                                                <td>{$user.uname}</td>
                                                <td>{$user.truename?:'<span class="text-info" data-toggle="tooltip" data-placement="left" title="姓名未填，当前显示昵称">'.$user.nicename.'</span>'}</td>
                                                <td><a href="{:url('users/user_list',['id'=>$user.tid])}">{$user.tname?:'系统顶级账号'}</a></td>

                                                <td>{$user.zt==1?'正常':($user.zt==2?'<span style="color:red">封号</span>':($user.zt==3?'冻结':$user.zt))}</td>
                                                <!-- <td style="max-width: 35px;overflow: hidden;" data-toggle="tooltip" data-placement="left" title="{$user.id|findsfz=###}">{$user.id|findsfz=###}</td> -->
                                                <td><a href="{:url('users/user_list',['tid'=>$user.id])}">{$user.tj_num}</a></td>
                                                <td>{$user.idc-$user.idc_freeze |round=###,2}</td>
                                                <td>{$user.id|user_b_count}</td>
                                                <td>{$user.id|user_kj_count}</td>
                                                <td>{$user.power}</td>
                                                <td>{$user.regtime|date='Y-m-d H:i:s',###}</td>
                                                <td title="{$user.regip}">{$user.ipinfo}</td>
                                                <td>
                                                    {if condition="$user.lasttime"}<span class="">{$user.lasttime|time_to_show=###}前</span>
                                                    {else /}<span class="text-danger">从未</span>
                                                    {/if}
                                                </td>
                                                <td>
                                                    <a href="#" onclick="resetpwd('{$user.uname}')" class="btn btn-xs btn-pink" data-toggle="tooltip" data-placement="top" title="重置密码">密</a>&nbsp;
                                                    <a href="#" onclick="update_zt('{$user.id}','{$user.zt==1?2:1}')" class="btn btn-xs btn-{$user.zt==1?'danger':'info'}" data-toggle="tooltip" data-placement="top" title="原因:{$user.reason}" id='zt_{$user.id}'>{$user.zt==1?'封号':'解封'}</a>&nbsp;
                                                    <a href="#" onclick="del_step4('{$user.id}')" class="btn btn-xs btn-danger" data-toggle="tooltip" data-placement="top" title="删除单个会员号！慎点">删</a>
                                                    <a href="{:url('users/user_list',['tid'=>$user.id])}" class="btn btn-xs btn-primary">直推</a>
                                                    {if condition="$user.shiming eq '0'"}<a href="{:url('users/shiming_do',['uid'=>$user.id])}" class="btn btn-xs btn-purple" data-toggle="tooltip" data-placement="top" title="用户实名认证">实名</a>
                                                    {else}<a href="{:url('users/shiming_do',['uid'=>$user.id])}" class="btn btn-xs btn-purple" data-toggle="tooltip" data-placement="top" title="实名信息">信息</a>
                                                    {/if}
                                                    <a href="{:url('caiwu/detail',['uname'=>$user.uname])}" class="btn btn-xs btn-pink" data-toggle="tooltip" data-placement="top" title="财务明细">财</a>&nbsp;
                                                </td>
                                            </tr>
                                        {/foreach}
                                        </tbody>
                                    </table>
                                    <div class="row">
                                        <div class="col-md-6">
                                            {$lists->render()}
                                        </div>
                                        <div class="col-md-6">
                                            <p>总数：{$lists->total()}</p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- Page End here -->
                </div>
                <!-- End .outlet -->
            </div>
            <!-- End .content-wrapper -->
            <div class="clearfix"></div>
        </div>
        
        <!-- End #content -->
        {include file="../view/foot" /}
        <script src="/public/theme/win10/assets/plugins/forms/checkall/jquery.checkAll.js"></script>
        <script>
            $('.table').checkAll({
                masterCheckbox: '.check-all',
                otherCheckboxes: '.check'
            });
            function del_step1(uid){
                var M_del_step1 = jqueryAlert({
                    'title'   : '警告',
                    'content' : '此操作不可恢复',
                    'modal'   : true,
                    'buttons' :{
                        '取消' : function(){
                            M_del_step1.destroy();
                        },
                        '删除' : function(){
                            M_del_step1.destroy();
                            del_step2(uid);
                        }
                    }
                })
            }
            function del_step2(uid){
                var M_del_step2 = jqueryAlert({
                    'title'   : '请输入操作密码',
                    'content' : '<input type="password" id="sispwd" class="form-control">',
                    'modal'   : true,
                    'buttons' :{
                        '取消' : function(){
                            M_del_step2.destroy();
                        },
                        '确定' : function(){
                            if($('#sispwd').val() == "{$setting.sispwd}"){
                                del_step3(uid);
                            }else{
                                jqueryAlert({
                                    'icon'    : '/public/chajian/alert-master/img/error.png',
                                    'content' : '操作密码错误',
                                    'closeTime' : 2000,
                                })
                            }
                            M_del_step2.destroy();
                        }
                    }
                })
            }
            function del_step3(uid){
                var _href = "{:url('users/user_del_fenxi')}/id/"+uid;
                var M_del_step3 = jqueryAlert({
                    'title'   : '删除用户分析',
                    'content' :  '<iframe src='+_href+' width="100%" height="100%" frameborder="0"></iframe>',
                    'modal'   : true,
                    'width'   : '360',
                    'buttons' :{
                        '取消' : function(){
                            M_del_step3.destroy();
                        },
                        '确定删除' : function(){
                            M_del_step3.destroy();
                            del_step4(uid)
                        }
                    }
                })
            }
            function del_step4(uid){
                if(window.confirm('你确定要删除吗？')){
                    //alert("确定");
                    var _href = "{:url('users/user_del_do')}/id/"+uid;
                    var M_del_step4 = jqueryAlert({
                        'style'   : 'pc',
                        'title'   : '用户清理中，请勿关闭！',
                        'content' :  '<iframe src='+_href+' width="100%" height="100%" frameborder="0"></iframe>',
                        'modal'   : true,
                        'contentTextAlign' : 'center',
                        'width'   : '90%',
                        'height'  : '90%',
                    });
                    $(".alert-btn-close").click(function(){
                        // M_del_step4.destroy();
                        location.reload();
                    });
                    return true;
                }else{
                    //alert("取消");
                    return false;
                }
            }
            function resetpwd(uname)    {
                var _content = '<div class="input-group mb5">';
                    _content += '<span class="input-group-addon">登陆密码</span>';
                    _content += '<input type="text" id="resetpwd" class="form-control" value="123456">';
                    _content += '</div>';
                    _content += '<div class="input-group">';
                    _content += '<span class="input-group-addon">支付密码</span>';
                    _content += '<input type="text" id="resetsecpwd" class="form-control" value="123456">';
                    _content += '</div>';
                var M_resetpwd = jqueryAlert({
                    'title'   : '重置 '+uname+' 密码',
                    'content' : _content,
                    'modal'   : true,
                    'buttons' :{
                        '取消' : function(){
                            M_resetpwd.destroy();
                        },
                        '重置' : function(){
                            var _resetpwd = $.trim($('#resetpwd').val());
                            var _resetsecpwd = $.trim($('#resetsecpwd').val());
                            M_resetpwd.destroy();
                            if(!_resetpwd || !_resetsecpwd){
                                jqueryAlert({
                                    'icon'    : '/public/chajian/alert-master/img/error.png',
                                    'content' : '密码不能为空',
                                    'closeTime' : 2000,
                                })
                            }else{
                                $.post("{:url('users/user_resetpwd')}",{"uname":uname,"pwd":_resetpwd,"secpwd":_resetsecpwd},function(data){
                                    console.log(data);
                                    if(data.zt==1){
                                        jqueryAlert({
                                            'icon'    : '/public/chajian/alert-master/img/right.png',
                                            'content' : data.msg,
                                            'closeTime' : 2000,
                                        })
                                    }else{
                                        jqueryAlert({
                                            'icon'    : '/public/chajian/alert-master/img/error.png',
                                            'content' : data.msg,
                                            'closeTime' : 2000,
                                        })
                                    }
                                }, "json");
                            }
                        }
                    }
                })
            }
            function update_zt(uid,value){
                var _content = '<div class="input-group mb5">';
                _content += '<span class="input-group-addon">原因</span>';
                _content += '<input type="text" id="reason" class="form-control">';
                _content += '</div>';
                var M_resetpwd = jqueryAlert({
                    'title'   : '请输入原因',
                    'content' : _content,
                    'modal'   : true,
                    'buttons' :{
                        '取消' : function(){
                            M_resetpwd.destroy();
                        },
                        '确定' : function(){
                            var reason = $.trim($('#reason').val());
                            M_resetpwd.destroy();
                            $.ajax({
                                url:"{:url('users/update_zt')}",
                                type:"post",
                                dataType:"json",
                                data:{"id":uid,"value":value,"reason":reason},
                                success:function(data){
                                    var M_del_step3 = jqueryAlert({
                                        'title'   : '修改状态结果',
                                        'content' :  data.message,
                                        'modal'   : true,
                                        'width'   : '360',
                                        'buttons' :{
                                            '确定' : function(){
                                                M_del_step3.destroy();
                                            }
                                        }
                                    });

                                    if(!data.is_error)
                                    {
                                        if(value==1)
                                        {
                                            $("#td_zt"+uid).html('<span style="color:green">正常</span>');
                                            $("#zt_"+uid).html('封号');
                                            $("#zt_"+uid).attr("onclick","update_zt('"+uid+"','2')");
                                            $("#zt_"+uid).removeClass('btn-info').addClass('btn-danger');
                                        }
                                        else
                                        {
                                            $("#td_zt"+uid).html('<span style="color:red">封号</span>');
                                            $("#zt_"+uid).html('正常');
                                            $("#zt_"+uid).attr("onclick","update_zt('"+uid+"','1')");
                                            $("#zt_"+uid).removeClass('btn-danger').addClass('btn-info');
                                        }

                                    }
                                    location.reload();
                                    setTimeout(function(){M_del_step3.destroy();},2000);
                                }
                            });
                        }
                    }
                })
            }
        </script>
    </body>
</html>